#include "Item.h"

#include "../ConsoleColor.h"
#include "../StringHelper.h"
#include <iostream>

Item::Item(const std::string &name, const std::string &description, const std::string &indefinite_article) 
	: GameObject(name,description,indefinite_article), stance(LAYING)
{
}

Item::~Item()
{
}

void Item::look() 
{ 
	std::string stance = getStanceAsString();
	if(stance.empty() == false)
		stance = " " + stance;
	std::cout << StringHelper::toUpper(getIndefiniteArticle()) << " " << yellow << name << white << stance << "." << std::endl;
}

std::string Item::getIndefiniteArticle()
{
    if(has(INDEF_ARTICLE_AN))
        return "an";
    else
        return GameObject::getIndefiniteArticle();
}

std::string Item::getStanceAsString()
{
    if(stance == IN_HAND)
        return "";
    else if(stance == IN_POCKET)
        return "";
    else if(has(STANCE_STAND))
        return "stands here";
    else if(has(STANCE_HOVER))
        return "hovers here";
    else if(has(STANCE_GROW))
        return "grows here";
    else if(stance == LAYING)
        return "lies here";
    else
        return "";
}

void Item::add(Setting setting)
{
	settings.push_back(setting);
}

bool Item::has(Setting setting)
{
	for(unsigned int i = 0; i < settings.size(); i++)
	{
		if(settings[i] == setting)
			return true;
	}
	return false;
}
